<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Insert title here</title>
    <link href="../css/bootstrap.min.css" rel="stylesheet">
    <script src="../js/jquery-1.11.3.js"></script>
	<script src="../js/bootstrap.min.js"></script>
	<script type="text/javascript">
		$(function () {
			loadUser();
			$("tbody").on("click",".change",function(){
				$.post("userlist",{uname:$(this).parents("tr").find(".uname").text()},function(){
					loadUser();
				})
			})
			$("#searchUser").click(function () {
				loadUser();
			})
		})
		function loadUser() {
			$.getJSON("userlist",{keyWord:($("#keyWord").val()==""?"":$("#keyWord").val())},function(json){
				$("tbody").empty();
				for (var i = 0; i < json.length; i++) {
					var line = "<tr><td>"+json[i].id+"</td><td class='uname'>"+json[i].userName+"</td><td>"+json[i].email+"</td><td><button class='change'>"+(json[i].status==true?'正常中':'黑名单')+"</button></td></tr>"
					$("tbody").append(line);
				}
			})
		}
	</script>
</head>
<body>
<div class="container">
    <div class="row">
        <nav class="navbar navbar-default">
            <div class="container-fluid">
                <div class="navbar-header">
                    <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
                        <span class="sr-only">Toggle navigation</span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                    </button>
                    <a class="navbar-brand" href="#">21Cake</a>
                </div>
                <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
                    <ul class="nav navbar-nav">
                        <li class="active"><a href="#">首页 <span class="sr-only">(current)</span></a></li>
                        <li><a href="#">Link</a></li>
                        <li class="dropdown">
                            <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">商品分类 <span class="caret"></span></a>
                            <ul class="dropdown-menu">
                                <li><a href="#">Action</a></li>
                                <li><a href="#">Another action</a></li>
                                <li><a href="#">Something else here</a></li>
                                <li role="separator" class="divider"></li>
                                <li><a href="#">Separated link</a></li>
                                <li role="separator" class="divider"></li>
                                <li><a href="#">One more separated link</a></li>
                            </ul>
                        </li>
                    </ul>
                    <div class="navbar-form navbar-left">
                        <div class="form-group">
                            <input type="text" class="form-control" placeholder="Search" id="keyWord" >
                        </div>
                        <button class="btn btn-default" id="searchUser">查询</button>
                    </div>
                    <ul class="nav navbar-nav navbar-right">
                    	<c:if test="${LoginAdmin!=null}">
                    	<li><a>${LoginAdmin.userName}</a></li>
                    	</c:if>
                        <li class="dropdown">
                            <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">用户中心<span class="caret"></span></a>
                            <ul class="dropdown-menu">
                                <li><a href="#">增加管理员</a></li>
                                <li><a href="#">修改密码</a></li>
                                <li><a href="adminLogin">注销</a></li>
                            </ul>
                        </li>
                    </ul>
                </div>
            </div>
        </nav>
    </div>
    <div class="row">
        <div class="col-md-2">
            <ul class="list-group">
                 <li class="list-group-item"><a href="orderlist.html">订单列表</a></li>
                <li class="list-group-item"><a href="userlist.jsp">用户列表</a></li>
                <li class="list-group-item"><a href="cakelist.html">商品列表</a></li>
                <li class="list-group-item"><a href="comm.html">评论列表</a></li>
            </ul>
        </div>
        <div class="col-md-10">
            <table class="table table-hover">
                <thead>
                <td>编号</td>
                <td>用户名</td>
                <td>邮箱</td>
                <td>状态</td>
                </thead>
                <tbody>
                
                </tbody>
            </table>
        </div>
    </div>
</div>
</body>
</html>